<?php
    namespace Admin\Controller;

    use Org\Util\Date;
    use Think\Controller;

    class MyController extends Controller
    {
        public function index()
        {

        }
        public function menuInfo(){
            $dishs= M('dish')->select();
            $a = array();
            foreach ($dishs as $dishInfo){
                $dish = new \stdClass();
                $dish->itemId = $dishInfo['dish_id'];
                $dish->name = $dishInfo['dish_name'];
                $dish->image = __ROOT__.'/'.$dishInfo['dish_icon'];
                $dish->desc = $dishInfo['dish_description'];
                $dish->price = $dishInfo['dish_price'];
                array_push($a,$dish);
            }

            return show(21000, "成功",$a);

        }
        public function showPicture(){
            $id = I('id');
            $data1['alt'] = '';
            $data1['pid'] = '';
//            $data1['src'] = __ROOT__.'/'.M('dish')->find()['dish_icon'];
            $data1['thumb'] = '';
            exit(json_encode($data1));
        }


        public function testDoing() {
            $a = array();

            $dish = array();
            $dish1 = new \stdClass();
            $dish1->itemId = "2466606555962";
            $dish1->name = "黄焖鸡米饭";
            $dish1->count = 3;
            $dish1->price = 12;
            $dish2 = new \stdClass();
            $dish2->itemId = "2466606555962";
            $dish2->name = "闽南餐厅";
            $dish2->count = 8;
            $dish2->price = 21;
            array_push($dish,$dish1);
            array_push($dish,$dish2);

            $rs = new \stdClass();
            $rs->tableNum = 2;
            $rs->orderId = "1466606555962";
            $rs->name = "桌号2";
            $rs->count = 11;
            $rs->price = 110;
            $rs->dish = $dish;
            array_push($a, $rs);

            exit(json_encode($a));
//            return show(21000, "成功",$a);

//            return show(21000, "成功",$a);
        }


        public function testTableItem() {
            $data_arr = array();

            $dataObj = new \stdClass();
            $dataObj->table_id  = 1;
            $dataObj->table_num   = 1;
            $dataObj->table_status = 0;

            $dataObj1 = new \stdClass();
            $dataObj1->table_id  = 2;
            $dataObj1->table_num   = 2;
            $dataObj1->table_status = 1;

            $dataObj2 = new \stdClass();
            $dataObj2->table_id  = 3;
            $dataObj2->table_num   = 3;
            $dataObj2->table_status = 0;

            $dataObj3 = new \stdClass();
            $dataObj3->table_id  = 4;
            $dataObj3->table_num   = 4;
            $dataObj3->table_status = 0;

            array_push($data_arr, $dataObj);
            array_push($data_arr, $dataObj1);
            array_push($data_arr, $dataObj2);
            array_push($data_arr, $dataObj3);


            $rs = new \stdClass();
            $rs->tableCount = 12;
            $rs->message    = "请求桌号成功";
            $rs->code       =  30011;
            $rs->data       =  $data_arr;


            $rs2 = new \stdClass();
            $rs2->tableCount = 12;

            $result = array(
                'code'=>30011,
                'message'=>"请求桌号成功",
                'tableCount'=>4,
                'data'=>$data_arr,
            );

//            return show(22001, "成功获取到桌号总数", $rs2);
            return show(30011, "成功获取到桌号总数", $data_arr);
        }

    }